#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@file:bisearch_number_game.py
@author:LifeTime
@date: 2018/05/05
@version:
    v1.0 2018-05-05 create
@input: 需要就写，不需要就不写
@output:需要就写，不需要就不写

* 折半猜数字（最多猜10次）
	* (给定一个1000以内的数字)
	* 提示用户："请想好一个1000以内的数字，我保证在10次以内猜中！"
	* 电脑给出一个结果，用户判断大/小/正确
	* 如果错误，提示剩余次数
	* 如果正确，给出提示并结束
"""
import time
start = 0
end =1000
print("Please think of a number within 1000, I promise to guess within 10 times!")
time.sleep(2)
for i in range(10):
    mid = (start + end) //2
    #print(start,mid,end,start + end //2)
    print(mid, "is big , small or right ?")
    answer = input("Pelse tell me :")
    if answer == 'big':
        end = mid - 1
        print("There are", 9-i, "chances left")
    elif answer == 'small':
        start = mid + 1
        print("There are", 9-i, "chances left")
    elif answer == 'right':
        print("I win! Thanks, game over! ")
        break
    else:
        print("Please enter the correct answer. Big, small or right?")
        print("There are", 9-i, "chances left")
    print("-"*25)
else:
    print("You cheated and I won!")